package com.qianyucc.blog.model.vo;

import cn.hutool.core.bean.*;
import cn.hutool.core.bean.copier.*;
import com.qianyucc.blog.model.entity.*;
import com.qianyucc.blog.utils.*;
import lombok.*;

import static com.qianyucc.blog.global.Constants.DEFAULT_DATE_TIME_PATTERN;

/**
 * @author lijing
 * @date 2019-10-21 10:39
 * @description 封装向前端返回的用户信息
 */
@Data
public class UserVO {
    public static UserVO create(UserDO userDO) {
        UserVO userVO = new UserVO();
        BeanUtil.copyProperties(userDO, userVO, CopyOptions.create().ignoreNullValue());
        userVO.setGmtCreate(Utils.formatDate(userDO.getGmtUpdate(), DEFAULT_DATE_TIME_PATTERN));
        userVO.setGmtUpdate(Utils.formatDate(userDO.getGmtCreate(), DEFAULT_DATE_TIME_PATTERN));
        return userVO;
    }

    private String id;
    private String name;
    private String login;
    private String avatarUrl;
    private String bio;
    private String token;
    private String gmtCreate;
    private String gmtUpdate;
}
